import { observable, action } from 'mobx'
import http from 'utils/http'

// 1, 热门申请；2，小编推荐
async function getList(type = 1) {
  const res = await http.get('card/list', { type })
  if (res.code === 1) {
    return res.data.data
  }
  throw new Error(res.info)
}

class CreditStore {
  @observable hotApplyList = []
  @observable recommendList = []

  @action
  async getHotApplyList() {
    const hotApplyList = await getList(1)
    this.hotApplyList = hotApplyList
  }

  async getRecommendList() {
    const recommendList = await getList(2)
    this.recommendList = recommendList
  }
}


const creditStore = new CreditStore()

export default creditStore
export { CreditStore }

